// timeUtils.js
function getTimestamp() {
    const now = new Date();
    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份补零
    const day = String(now.getDate()).padStart(2, '0'); // 日期补零
    const hours = String(now.getHours()).padStart(2, '0'); // 小时补零
    const minutes = String(now.getMinutes()).padStart(2, '0'); // 分钟补零
    const seconds = String(now.getSeconds()).padStart(2, '0'); // 秒补零

    // 格式化时间戳
    const timestamp = `${year}${month}${day}_${hours}${minutes}${seconds}`;
    return timestamp;
}

function getTimestampMs() {
    const now = new Date();
    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份补零
    const day = String(now.getDate()).padStart(2, '0'); // 日期补零
    const hours = String(now.getHours()).padStart(2, '0'); // 小时补零
    const minutes = String(now.getMinutes()).padStart(2, '0'); // 分钟补零
    const seconds = String(now.getSeconds()).padStart(2, '0'); // 秒补零
    const milliseconds = String(now.getMilliseconds()).padStart(3, '0'); // 毫秒补零

    // 格式化时间戳
    const timestamp = `${year}${month}${day}_${hours}${minutes}${seconds}${milliseconds}`;
    return timestamp;
}

module.exports = { getTimestamp, getTimestampMs };
